package DesignPattern.PrototypePattern.demo1;

import java.io.*;
import java.util.Date;

/**
 * Created by User on 2017/12/18.
 */
public class WeeklyLog implements Serializable {
    Long id;
    String name;
    Date date;
    String content;

    public WeeklyLog deepClone() throws IOException, ClassNotFoundException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
        objectOutputStream.writeObject(this);

        ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
        Object object = objectInputStream.readObject();

        return (WeeklyLog) object;
    }

    public Long getId() {
        return id;
    }

    public WeeklyLog setId(Long id) {
        this.id = id;
        return this;
    }

    public String getName() {
        return name;
    }

    public WeeklyLog setName(String name) {
        this.name = name;
        return this;
    }

    public Date getDate() {
        return date;
    }

    public WeeklyLog setDate(Date date) {
        this.date = date;
        return this;
    }

    public String getContent() {
        return content;
    }

    public WeeklyLog setContent(String content) {
        this.content = content;
        return this;
    }
}
